#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Au3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 6 -w 7 -d
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#Region Organize Includes
#include "ImageMagickObject Object.au3"
#include "AutoItObject.au3"
#include <Misc.au3>
#EndRegion Organize Includes

_Singleton(@ScriptName)

; two test images are located here...
Global Const $testImage = @ScriptDir & "\Test Images\Image4.jpg"
Global Const $testImage2 = @ScriptDir & "\Test Images\Image2.jpg"
Global Const $testImagePNG = @ScriptDir & "\Test Images\drawn.png"

; this is the directory that images are placed in after ImageMagick does its thing...
Global Const $DestinationDir = @ScriptDir & "\Pictures\"

_AutoItObject_Startup()

Global $ImageMagick = ImageMagickObject()

; 'True' lets ImageMagickObject Object set its own error handler.  Set to 'false' if you plan to use your own.
$ImageMagick.Startup(True)

HotKeySet("{ESC}", "_Exit")
OnAutoItExitRegister("term")

#Region Get and display the properties of one of the test images in the console...
ConsoleWrite("Height:    " & $ImageMagick.Height($testImage) & @CRLF)
ConsoleWrite("Width:     " & $ImageMagick.Width($testImage) & @CRLF)
ConsoleWrite("Extension: " & $ImageMagick.Extension($testImage) & @CRLF)
ConsoleWrite("Name:      " & $ImageMagick.Name($testImage) & @CRLF)
ConsoleWrite("FileName:  " & $ImageMagick.FileName($testImage) & @CRLF)
#EndRegion Get and display the properties of one of the test images in the console...

If FileExists($DestinationDir) Then DirRemove($DestinationDir, 1)

DirCreate($DestinationDir)
DirCreate($DestinationDir & "Cropped\")
DirCreate($DestinationDir & "Encrypt\")

$ImageMagick.AdaptiveBlur($testImage, $DestinationDir & "Adaptive Blur.jpg", 10, 10)
$ImageMagick.AdaptiveSharpen($testImage, $DestinationDir & "Adaptive Sharpen.jpg", 10, 50)
$ImageMagick.AdaptiveResize($testImage, $DestinationDir & "Adaptive Resize.jpg", "50%")
$ImageMagick.Annotate($testImage, $DestinationDir & "Annotate.jpg", 180, "Wonky") ; Puts a text label on your image.  doesn't work too well
$ImageMagick.AutoGamma($testImage, $DestinationDir & "AutoGamma.jpg") ; Adjust gamma automagically
$ImageMagick.AutoLevel($testImage, $DestinationDir & "AutoLevel.jpg") ; Adjust level automagically
$ImageMagick.AutoOrient($testImage, $DestinationDir & "AutoOrient.jpg") ; Adjust orientation automagically
$ImageMagick.BlackThreshold($testImage, $DestinationDir & "Black Threshold.jpg", "60%")
$ImageMagick.BlueShift($testImage, $DestinationDir & "BlueShift.jpg", 1.5) ; Make your image look like it was taken at night -- sort of.
$ImageMagick.Blur($testImage, $DestinationDir & "Blur.jpg", 10) ; make your image blurry
$ImageMagick.Brightness($testImage, $DestinationDir & "Brightness.jpg", 25) ; Alter the brightness of your image.
$ImageMagick.Charcoal($testImage, $DestinationDir & "Charcoal.jpg", -5) ; simulate a charcoal drawing, yeah ok
$ImageMagick.Contrast($testImage, $DestinationDir & "Contrast.jpg", 50) ; adjust contrast by specified amount
$ImageMagick.Crop($testImage, $DestinationDir & "Cropped\Cropped%002.jpg", 60)
$ImageMagick.Implode($testImage, $DestinationDir & "Implode.jpg", 2) ; implodes an image toward the center.
$ImageMagick.Negate($testImage, $DestinationDir & "Negate.jpg") ; Make your image look like a photo negative.
$ImageMagick.Normalize($testImage, $DestinationDir & "Normalize.jpg") ; Does something to your image called normalize.
$ImageMagick.Modulate($testImage, $DestinationDir & "Modulate.jpg", 120, 90, 50) ; does something called modulate to the image
$ImageMagick.Monochrome($testImage, $DestinationDir & "Monochrome.jpg") ; convert your image to monochrome
$ImageMagick.Paint($testImage, $DestinationDir & "Paint.jpg", 1.5) ; Makes your image kinda sorta look like an oil painting in a way.
$ImageMagick.Resize($testImage, $DestinationDir & "Resize400.jpg", 400) ; Use this to resize an image. Useful for making thumbnails.
$ImageMagick.Rotate($testImage, $DestinationDir & "Rotate90.jpg", 90) ; rotate your image by 90 degrees
$ImageMagick.Rotate($testImage, $DestinationDir & "Rotate-90.jpg", -90) ; -90 degrees
$ImageMagick.Rotate($testImage, $DestinationDir & "Rotate180.jpg", 180) ; 180 degrees
$ImageMagick.Rotate($testImage, $DestinationDir & "Rotate300.jpg", 300) ; 300 degrees
$ImageMagick.Spread($testImage, $DestinationDir & "Spread.jpg", 8) ; randomly spreads your pixels around a given pixel neighborhood

; encrypt an image -- doesn't work with jpg and gif
$ImageMagick.Encipher($testImagePNG, $DestinationDir & "Encrypt\Encipher.png", @ScriptDir & "\PassPhrase.txt")
$ImageMagick.Decipher($DestinationDir & "Encrypt\Encipher.png", $DestinationDir & "Encrypt\Decipher.png", @ScriptDir & "\PassPhrase.txt")

#Region Let us do some operations on a list of images...
; pass the images as an array ...
Global Const $imageList[2] = [$testImage, $testImage2]

; or as a comma seperated list ...
;~ Global Const $imageList = $testImage & "," & $testImage2

; or to append every (jpg|gif|png|et cetera) image in a directory!
;~ Global Const $imageList = @ScriptDir & "\Test Images\*.jpg"

$ImageMagick.Append($imageList, $DestinationDir & "Append.jpg")
$ImageMagick.Append($imageList, $DestinationDir & "AppendCenter.jpg"   , '', "Center", '')
$ImageMagick.Append($imageList, $DestinationDir & "AppendRed1.jpg"     , '', ''      , 0xFF0000)
$ImageMagick.Append($imageList, $DestinationDir & "AppendGreen2.jpg"   , '', ''      , 0x00FF00)
$ImageMagick.Append($imageList, $DestinationDir & "AppendBlue3.jpg"    , '', ''      , 0x0000FF)
$ImageMagick.Append($imageList, $DestinationDir & "AppendCenterRed.jpg", '', "Center", 0xFF0000)
#EndRegion Let us do some operations on a list of images...

Func _exit()
	Exit
EndFunc   ;==>_exit

Func term()
	ShellExecute($DestinationDir) ; let the user see the images after completion
EndFunc   ;==>term
